<link rel="stylesheet" href="../../../../public/static/admin/css/ace.min1.css">{extend name="index/index" /}
{block name="mycss"}
<link rel="stylesheet" href="/static/admin/css/ace.min1.css"/>
{/block}
<!--main-->
{block name="main"}
<div class="main-content">
    <div class="breadcrumbs" id="breadcrumbs">
        <script type="text/javascript">
            try {
                ace.settings.check('breadcrumbs', 'fixed')
            } catch (e) {
            }
        </script>

        <ul class="breadcrumb">
            <li>
                <i class="icon-home home-icon"></i>
                <a href="#">Home</a>
            </li>

            <li>
                <a href="/goods">图片管理</a>
            </li>
            <li class="active">已审核图片</li>
                <form style="margin-left:250px;margin-top:-23px">
                    <input type="text" name="search" placeholder="请输入图片名">
                    <button class="btn btn-xs btn-info">搜索</button>
                </form>
        </ul><!-- .breadcrumb -->

    </div>

    <form action="{:url('admin/goods/dela')}" method="post">
    <div class="page-content">
        <div class="page-header">
            <h1>
                图片
                <small>
                    <i class="icon-double-angle-right"></i>
                    用户上传图片（审核）
                </small>

                <button type="submit" class="btn btn-xs btn-danger dell-btn" >批量删除</button>
                <a  href="{:url('admin/goods/index',['type'=>'push'])}" class="btn btn-xs btn-success " >显示推送图片</a>

            </h1>
        </div><!-- /.page-header -->
        <div class="row">
            <div class="col-xs-12">
                <!-- PAGE CONTENT BEGINS -->

                <div class="row">
                    <div class="col-xs-12">
                        <div class="table-responsive">
                            <table id="sample-table-2" class="table table-striped table-bordered table-hover">
                                <thead>
                                <tr>
                                    <th class="center" style="width:100px">
                                        <label>
                                            <input type="checkbox" class="ace"/>
                                            <span class="lbl"></span>
                                        </label>
                                    </th>
                                    <th style="width:100px">编号</th>
                                    <th style="width:100px">UID</th>
                                    <th class="hidden-480" style="width:100px">描述</th>
                                    <th style="width:200px">
                                        <i class=" icon-folder-close
 bigger-110 hidden-480"></i>
                                        图片
                                    </th>
                                    <th class="hidden-480" style="width:300px">推送至首页(2-电影/3-动物/4-二次元/5-体育/6-游戏)</th>
                                    <th class="hidden-480" style="width:130px">审核状态</th>
                                </tr>
                                </thead>

                                <tbody>

                                {volist name="list" id="v"}
                                <!--tr-->
                                <tr>
                                    <td class="center" >
                                        <label>
                                            <input type="checkbox" value="{$v['id']}" name="info[]" class="ace"/>
                                            <span class="lbl"></span>
                                        </label>
                                    </td>

                                    <td >
                                        <a href="#">{$v['id']}</a>
                                    </td>

                                    <td >{$v['uid']}</td>
                                    <td class="hidden-480" >{$v['pname']}</td>
                                    <td>
                                        <img class="show-img" src="http://pdyc9epam.bkt.clouddn.com/{$v['icon']}" style="width:250px">
                                        <span class="label label-danger arrowed-in-right arrowed del-img" data-id="{$v['id']}" >永久删除</span>
                                    </td>


                                    <td class="hidden-480" >

                                        第
                                        <button type="button" class="row-btn btn btn-info btn-xs" data-row="2" data-id="{$v['id']}">2</button>
                                        <button type="button" class="row-btn btn btn-danger btn-xs" data-row="3" data-id="{$v['id']}">3</button>
                                        <button type="button" class="row-btn btn btn-success btn-xs" data-row="4" data-id="{$v['id']}">4</button>
                                        <button type="button" class="row-btn btn btn-warning btn-xs" data-row="5" data-id="{$v['id']}" >5</button>
                                        <button type="button" class="row-btn btn btn-info btn-xs" data-row="6" data-id="{$v['id']}" >6</button>
                                        行

                                            {if condition="($v['row'])"}
                                        <span class=" badge badge-pink">
                                    (目前第{$v['row']}行)
                                        </span>
                                        {else/}
                                        <span></span>
                                    {/if}
                                        <button type="button" class="row-btn btn btn-active btn-xs" data-row="0" data-id="{$v['id']}">取消</button>
                                    </td>


                                    <td >

                                        {switch name="v.check"}
                                        {case value="2"} <input id="id-button-borders"  data-id="{$v['id']}" data-status="{$v['check']}" type="checkbox" class="check-btn ace ace-switch ace-switch-5" >
                                        <span class="lbl"></span>{/case}
                                        {case value="1"} <input id="id-button-borders"  data-id="{$v['id']}" data-status="{$v['check']}" type="checkbox" checked="cheched" class="check-btn ace ace-switch ace-switch-5" >
                                        <span class="lbl"></span>{/case}
                                        {/switch}

                                    </td>
                                </tr>

                                <!--endtr-->
                                {/volist}
    </form>
                                </tbody>
                            </table>
    <div class="row">
        <div class="col-md-12" style="text-align:center;">
            {$page}
        </div>
    </div>

                        </div>
                    </div>
                </div>

                <div id="modal-table" class="modal fade" tabindex="-1">
                    <div class="modal-dialog">
                        <div class="modal-content">
                            <div class="modal-header no-padding">
                                <div class="table-header">
                                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                                        <span class="white">&times;</span>
                                    </button>
                                    Results for "Latest Registered Domains
                                </div>
                            </div>

                            <div class="modal-body no-padding">
                                <table class="table table-striped table-bordered table-hover no-margin-bottom no-border-top">
                                    <thead>
                                    <tr>
                                        <th>编号</th>
                                        <th>姓名</th>
                                        <th>级别</th>

                                        <th>
                                            <i class="icon-time bigger-110"></i>
                                            Update
                                        </th>
                                    </tr>
                                    </thead>

                                    <tbody>
                                    <tr>
                                        <td>
                                            <a href="#">ace.com</a>
                                        </td>
                                        <td>$45</td>
                                        <td>3,330</td>
                                        <td>Feb 12</td>
                                    </tr>

                                    <tr>
                                        <td>
                                            <a href="#">base.com</a>
                                        </td>
                                        <td>$35</td>
                                        <td>2,595</td>
                                        <td>Feb 18</td>
                                    </tr>

                                    <tr>
                                        <td>
                                            <a href="#">max.com</a>
                                        </td>
                                        <td>$60</td>
                                        <td>4,400</td>
                                        <td>Mar 11</td>
                                    </tr>

                                    <tr>
                                        <td>
                                            <a href="#">best.com</a>
                                        </td>
                                        <td>$75</td>
                                        <td>6,500</td>
                                        <td>Apr 03</td>
                                    </tr>

                                    <tr>
                                        <td>
                                            <a href="#">pro.com</a>
                                        </td>
                                        <td>$55</td>
                                        <td>4,250</td>
                                        <td>Jan 21</td>
                                    </tr>
                                    </tbody>
                                </table>
                            </div>

                            <div class="modal-footer no-margin-top">
                                <button class="btn btn-sm btn-danger pull-left" data-dismiss="modal">
                                    <i class="icon-remove"></i>
                                    Close
                                </button>

                                <ul class="pagination pull-right no-margin">
                                    <li class="prev disabled">
                                        <a href="#">
                                            <i class="icon-double-angle-left"></i>
                                        </a>
                                    </li>

                                    <li class="active">
                                        <a href="#">1</a>
                                    </li>

                                    <li>
                                        <a href="#">2</a>
                                    </li>

                                    <li>
                                        <a href="#">3</a>
                                    </li>

                                    <li class="next">
                                        <a href="#">
                                            <i class="icon-double-angle-right"></i>
                                        </a>
                                    </li>
                                </ul>
                            </div>
                        </div><!-- /.modal-content -->
                    </div><!-- /.modal-dialog -->
                </div><!-- PAGE CONTENT ENDS -->
            </div><!-- /.col -->
        </div><!-- /.row -->
</div><!-- /.main-content -->

</div><!-- /.main-container-inner -->


<a href="#" id="btn-scroll-up" class="btn-scroll-up btn btn-sm btn-inverse">
    <i class="icon-double-angle-up icon-only bigger-110"></i>
</a>
</div><!-- /.main-container -->

<!-- Modal -->
<!--<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">-->
    <!--<div class="modal-dialog" role="document">-->
        <!--<div class="modal-content">-->
            <!--<div class="modal-header">-->
                <!--<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span>-->
                <!--</button>-->
                <!--<h4 class="modal-title" id="myModalLabel"></h4>-->
            <!--</div>-->
            <!--<div class="modal-body">-->
                <!--<div class="row">-->
                    <!--<div class="col-md-4">-->
                        <!--<img id="icon" class="img-responsive" src="" width="150px">-->
                    <!--</div>-->

                    <!--<div class="col-md-8">-->
                        <!--<table class="table table-hover table-bordered">-->
                            <!--<tr>-->
                                <!--<th>编号</th>-->
                                <!--<th>姓名</th>-->
                                <!--<th> 电话</th>-->
                                <!--<th>最后修改时间</th>-->
                                <!--<th>状态</th>-->
                            <!--</tr>-->

                            <!--<tr>-->
                                <!--<td id="td1"></td>-->
                                <!--<td id="td2"></td>-->
                                <!--<td id="td3"></td>-->
                                <!--<td id="td4"></td>-->
                                <!--<td id="td5"></td>-->
                            <!--</tr>-->

                        <!--</table>-->
                    <!--</div>-->
                <!--</div>-->
            <!--</div>-->
            <!--<div class="modal-footer">-->
                <!--<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>-->
            <!--</div>-->
        <!--</div>-->
    <!--</div>-->
<!--</div>-->
<!-- endModal -->


{/block}
<!-- basic scripts -->

<!--[if !IE]> -->

<script src="/static/admin/js/jquery.min.js"></script>

<!-- <![endif]-->

{block name="myjs" }
<!--[if IE]>
<script src="/static/admin/js/1.10.2/jquery.min.js"></script>
<![endif]-->

<!--[if !IE]> -->

<script type="text/javascript">
    window.jQuery || document.write("<script src='/static/admin/js/jquery-2.0.3.min.js'>" + "<" + "/script>");
</script>

<!-- <![endif]-->

<!--[if IE]>
<script type="text/javascript">
    window.jQuery || document.write("<script src='/static/admin/js/jquery-1.10.2.min.js'>" + "<" + "/script>");
</script>
<![endif]-->

<script type="text/javascript">
    if ("ontouchend" in document) document.write("<script src='/static/admin/js/jquery.mobile.custom.min.js'>" + "<" + "/script>");
</script>
<script src="/static/admin/js/bootstrap.min.js"></script>
<script src="/static/admin/js/typeahead-bs2.min.js"></script>

<!-- page specific plugin scripts -->

<script src="/static/admin/js/jquery.dataTables.min.js"></script>
<script src="/static/admin/js/jquery.dataTables.bootstrap.js"></script>

<!-- ace scripts -->

<script src="/static/admin/js/ace-elements.min.js"></script>
<script src="/static/admin/js/ace.min.js"></script>

<!-- inline scripts related to this page -->

<script type="text/javascript">

    toastr.options = {
        closeButton: true,// 是否显示关闭按钮
        progressBar: false,// 实现显示计时条
        timeOut: "2000",  // 自动关闭时间
        // positionClass: "toast-bottom-left" // 提示位置
        positionClass: "toast-top-full-width" // 提示位置
        // toast-top-full-width 顶端，宽度铺满整个屏幕
        // toast-top-right  顶端右边
    };

    $('.dell-btn').click(function(){
        if(!confirm('确定要删除所有选中信息吗')){
            return false;
        }
    })

    $('.row-btn').click(function(){
        var row=$(this).attr('data-row');
        var id=$(this).attr('data-id');
        var obj=$(this);
        var str=$(this).parent('td').children('span').html();
            rowAjax(row,id,obj);    
    })

    function rowAjax(row,id,obj)
    {
        $.ajax({
            type:'post',
            dataType:'json',
            url:'/row',
            data:{'row':row,'id':id},
            success:function(data){
                if(data.num=='取消'){
                    obj.parent('td').children('span').html('');
                    return toastr.success(data.info);
                }

                if(data.status){
                    obj.parent('td').children('span').html('(目前第'+row+'行)');
                    obj.parent('td').children('span').addClass('badge badge-pink');
                    toastr.success(data.info);
                }else{
                    toastr.error(data.info);
                }
            },
            error:function(){
            }
        })
    }







    $('.del-img').click(function(){
        var id=$(this).attr('data-id');
        var tr=$(this).parents('tr');
        if(confirm('确定要[删除]这张图片吗')){
            delAjax(id,tr);
        }
    })

    function delAjax(id,tr)
    {
        $.ajax({
            type:'delete',
            data:{'id':id },
            dataType:'json',
            url:'/delimg',
            success:function(data){
                if(data.status){
                    tr.remove();
                    toastr.success('删除成功');
                }else{
                    toastr.error('删除失败,请稍后再试');
                }
            },
            error:function(){
            }
        })
    }



    $('.show-img').mouseover(function(){
        $('.show-imgs').show();
    })

    $('.show-img').mouseout(function(){
        $('.show-imgs').hide();
    })


     $('.check-btn').click(function(){
         var id=$(this).attr('data-id');
         var obj =$(this);
         var tr =$(this).parents('tr');
         if($(this).attr('data-status')=='2'){
             checkAjax(id,'1',obj,tr);
         }else{
             checkAjax(id,'2',obj,tr);
         }
     })

    function checkAjax(id,status,obj,tr)
    {
        $.ajax({
            type:'post',
            data:{'id':id ,'status':status},
            dataType:'json',
            url:'/check',
            success:function(data){
                if(data){
                    if(data.info=='1'){
                        obj.attr('data-status',1);
                        tr.remove();
                        toastr.success('id为'+id+'的图片审核通过');
                    }else{
                        obj.attr('data-status',2);
                        tr.remove();
                        toastr.error('id为'+id+'的图片审核不通过');
                    }
                }else{
                    alert('修改失败,请稍后再试');
                }

            },
            error:function(){


            }




        })

    }










//    $('.del-btn').click(function () {
//        var del_id = $(this).attr('data-id');
//        var tr = $(this).parents('tr');
//        if (confirm('您确定要[删除]该用户吗')) {
//            delAjax(del_id, tr);
//        }
//    })
//
//    function delAjax(id, tr) {
//        $.ajax({
//            type: 'delete',
//            dataType: 'json',
//            url: 'user/' + id,
//            success: function (data) {
//                if (data.status) {
//                    toastr.success(data.info);
//                    tr.remove();
//                } else {
//                    toastr.error(data.info, '警告');
//                }
//            },
//            error: function () {
//
//
//            },
//        });
//    }
//
//
//    //    $('.show-btn').click(function(){
//    //        var show_id=$(this).attr('data-id');
//    //        showAjax(show_id);
//    //    });
//
//    $('.show-btn').click(function () {
//        var show_id = $(this).attr('data-id');
//        showAjax(show_id);
//    });
//
//    function showAjax(id) {
//        $.ajax({
//            type: 'get',
//            dataType: 'json',
//            url: 'user/' + id,
//            success: function (data) {
//                console.log(data.info.icon);
//
//                switch (data.info.status) {
//                    case 1:
//                        data.info.status = '激活';
//                        break;
//                    case 2:
//                        data.info.status = '禁用';
//                        break;
//                }
//
//                if (data.status) {
//                    $('h4').html(data.title);
//                    td1.innerHTML = id;
//                    td2.innerHTML = data.info.name;
//                    td3.innerHTML = data.info.tel;
//                    td4.innerHTML = data.info.modify_time;
//                    td5.innerHTML = data.info.status;
//                    var str = data.info.icon;
//                    var pic = str.replace(/'/g, "");
//                    console.log(pic);
//                    $('#icon').attr('src', pic + "?flag=" + Math.random());
//                } else {
//                    $('h4').html(data.title);
//                }
//
//            },
//            error: function () {
//
//
//            },
//        });
//    }


    jQuery(function ($) {
        var oTable1 = $('#sample-table-2').dataTable({
            "aoColumns": [
                {"bSortable": false},
                null, null, null, null, null,
                {"bSortable": false}
            ]
        });


        $('table th input:checkbox').on('click', function () {
            var that = this;
            $(this).closest('table').find('tr > td:first-child input:checkbox')
                .each(function () {
                    this.checked = that.checked;
                    $(this).closest('tr').toggleClass('selected');
                });

        });


        $('[data-rel="tooltip"]').tooltip({placement: tooltip_placement});
        function tooltip_placement(context, source) {
            var $source = $(source);
            var $parent = $source.closest('table')
            var off1 = $parent.offset();
            var w1 = $parent.width();

            var off2 = $source.offset();
            var w2 = $source.width();

            if (parseInt(off2.left) < parseInt(off1.left) + parseInt(w1 / 2)) return 'right';
            return 'left';
        }
    })

</script>
{/block}

<div style="display:none">
    <script src='http://v7.cnzz.com/stat.php?id=155540&web_id=155540' language='JavaScript' charset='gb2312'></script>
</div>
</body>
</html>
